import time

last_open_time = {}  # 全局变量记录上次开仓时间

def open_position(symbol):
    current_time = time.time()
    if symbol in last_open_time and current_time - last_open_time[symbol] < 5:  # 5秒内不重复开仓
        return False
    last_open_time[symbol] = current_time
    # 执行开仓逻辑
    return True

def check_order_status(symbol, order_status):
    if order_status in ['ALIVE', 'PARTIAL_FILLED', 'PENDING']:  # 所有非终态
        return False, f"{symbol}有未完成订单（状态: {order_status}）"
    return True, None

# 其他业务逻辑...